﻿--[[
   @brief    game or plugin state_operation logic for  mianframe right bottom
   @author   harleyxwang
   @version  1.0
   @date     2016-10-13
--]]

frame_bottom_res = {
    kProgressBarNormal = "9IMAGES:bottom_bar\\progress.png?0,19,6,23;bottom_bar\\progress.png?8,19,14,23;bottom_bar\\progress.png?16,19,22,23;bottom_bar\\progress.png?0,25,6,26;bottom_bar\\progress.png?8,25,14,26;bottom_bar\\progress.png?16,25,22,26;bottom_bar\\progress.png?0,28,6,32;bottom_bar\\progress.png?8,28,14,32;bottom_bar\\progress.png?16,28,22,32;Stretch;0;";
    kProgressBarPaused = "9IMAGES:bottom_bar\\progress.png?0,36,6,40;bottom_bar\\progress.png?8,36,14,40;bottom_bar\\progress.png?16,36,22,40;bottom_bar\\progress.png?0,42,6,43;bottom_bar\\progress.png?8,42,14,43;bottom_bar\\progress.png?16,42,22,43;bottom_bar\\progress.png?0,45,6,49;bottom_bar\\progress.png?8,45,14,49;bottom_bar\\progress.png?16,45,22,49;Stretch;0;";
};

frame_bottom_progress_type = {
    kProgressNormal = 0;
    kProgressFileSize = 1;
};

dlcState = {
    NoOwned = 0,
    NoInstalled = 1,
    Downloading = 2,
    DownloadingPause = 3,
    DownloadFailed = 4,
    DownloadOk = 5,
    InstallCanceled = 6,
    Installing = 7,
    InstalledOk = 8,
    NeedUpdate = 9,
    Updating = 10,
    WaitingForInstall = 11,
    InstalledFailed = 12,
    DiskSizeNotAvaialable = 13,
    GameIsRunning = 14,
    GameIsInstalling = 15,
    GameIsUpdating = 16,
    GameIsRemoving = 17,
    GameStateUnknow = 18,
    DlcNotFound = 19, -- 下载失败(文件未找到)
    ServerDlcConfigError = 20, -- 下载失败(服务器配置错误)
    NoDownloadDlcUrl = 21, -- 下载失败(无下载地址)
    DownloadDlcUrlInvalidate = 22, -- 下载失败(下载地址格式错误)
    DownloadMgrError = 23, -- 下载失败(下载组件错误)
    DownloadTimeout = 24, -- 下载失败(请求超时)
    DownloadTaskRepairFailed = 25, -- 下载失败(任务修复失败)
    DownloadCreateFileFailed = 26, -- 下载失败(创建文件失败)
    DownloadWriteFileFailed = 27, -- 下载失败(写入文件失败)
    DownloadUrlTargetNotExist = 28, -- 下载失败(下载地址错误)
    DownloadDisConnect = 29, -- 下载失败(连接断开)
    DownloadOverWriteFileFailed = 30, -- 下载失败(覆盖文件失败)
    DownloadNoDataTimeOut = 31, -- 下载失败(无数据返回)
    QueryServerDlcListError = 32, -- 下载失败(查询DLC列表失败)
    UnzipDlcZipError = 33, -- 安装失败(解压文件失败)
    ExeConfigError = 34, -- 安装失败(执行配置文件失败)
    DlcZipNotExists = 35, -- 安装失败(压缩包不存在)
    BackupDlcFilesError = 36, -- 安装失败(备份文件失败)
    RestoreDlcFilesError = 37, -- 安装失败(恢复文件失败)
    DownloadFailedStillRemoveLastDlcFiles = 38, -- 下载失败(文件清理中)
    UnKnowError = 39, -- 未知错误
    QueryGameAuthorityFailed = 40, -- 查询游戏权限失败
    GameNotInstalled = 41, -- 未安装游戏
    GameDownloadFailed = 42, -- 游戏下载失败
    DlcMd5IsNull = 43, -- 没有为DLC配置MD5
    DlcMd5NotMatch = 44, -- MD5不匹配
    UpdateFailed = 45, -- DLC更新失败
    StateNone = 46,
    OfflineMode = 47,
    DlcListGetFailed = 48,
    DlcDownloadLimited = 49,
    DlcQueryRepoFailed = 50,   -- 查询DLC REPO 失败
    DlcRepoNoDownloadRight = 51,  --  没有这个DLC的下载权限
};

state_operation_panel =
{
    operation_btn_background_ = {};
    operation_cloud_btn_background_ = {};
    operation_btn_using_background_ = {};
    state_btn_background_ = {};
    ierd_tgp.tpf_ui.Require("TPFLocalization.lua");

    is_english_ver = false;
    self_user_id_ = nil;
    is_cloud_game_ = false;
    cur_game_state_ = nil;
    cur_game_sub_state_ = nil;
    cur_game_id_ = 0;
    cur_updating_dlc_id_ = 0;
    cur_dlc_state_ = 0;

    progress_info_type = frame_bottom_progress_type.kProgressNormal;
    progress_info_tick = 0;

    init = function()
        ierd_tgp.tpf_ui.Log("state_operation_panel init.");
        local tpfui =
                base_utility.get_component_adapter("ITpf_ui",
                    "ierd_tgp.tpf_ui.GetTPFUI();");

        state_operation_panel.is_english_ver = tpfui:Is_English_ver();
        state_operation_panel.operation_btn_background_[ierd_tgp.game_library.GAME_STATE_NORMAL] = {
                                        background = "ONEIMAGE:bottom_bar\\start.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\play_hover.tfc;Stretch;0",
                                     };
        state_operation_panel.operation_btn_background_[ierd_tgp.game_library.GAME_STATE_NEED_UPDATE] = {
                                        background = "ONEIMAGE:bottom_bar\\update_normal.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\update_hover.png;Stretch;0;",
                                     };
        state_operation_panel.operation_btn_background_[ierd_tgp.game_library.GAME_STATE_UPDATE_FAIL] = {
                                        background = "ONEIMAGE:bottom_bar\\re_update_normal.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\re_update_hover.png;Stretch;0;",
                                     };
        state_operation_panel.operation_btn_background_[ierd_tgp.game_library.GAME_STATE_NOT_INSTALLED] = {
                                        background = "ONEIMAGE:bottom_bar\\download_normal.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\download_hover.png;Stretch;0;",
                                     };
        state_operation_panel.operation_btn_background_[ierd_tgp.game_library.GAME_STATE_DOWNLOADED] = {
                                        background = "ONEIMAGE:bottom_bar\\install_normal.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\install_hover.png;Stretch;0;",
                                     };
        state_operation_panel.operation_btn_background_[ierd_tgp.game_library.GAME_STATE_DOWNLOAD_FAIL] = {
                                        background = "ONEIMAGE:bottom_bar\\re_download_normal.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\re_download_hover.png;Stretch;0;",
                                     };
        state_operation_panel.operation_btn_background_[ierd_tgp.game_library.GAME_STATE_BROKEN] = {
                                        background = "ONEIMAGE:bottom_bar\\re_download_normal.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\re_download_hover.png;Stretch;0;",
                                     };
        state_operation_panel.operation_btn_background_[25] = {
                                        background = "ONEIMAGE:bottom_bar\\update_plugin_normal.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\update_plugin_hover.png;Stretch;0;",
                                     };
                                     
        --   operation_cloud_btn_background_                 
        state_operation_panel.operation_cloud_btn_background_[ierd_tgp.game_library.GAME_STATE_NORMAL] = {
                                        background = "ONEIMAGE:bottom_bar\\with_menu\\start.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\with_menu\\start_hover.png;Stretch;0",
        };
        state_operation_panel.operation_cloud_btn_background_[ierd_tgp.game_library.GAME_STATE_NEED_UPDATE] = {
                                        background = "ONEIMAGE:bottom_bar\\with_menu\\update_normal.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\with_menu\\update_hover.png;Stretch;0;",
                                     };
        state_operation_panel.operation_cloud_btn_background_[ierd_tgp.game_library.GAME_STATE_UPDATE_FAIL] = {
                                        background = "ONEIMAGE:bottom_bar\\with_menu\\re_update_normal.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\with_menu\\re_update_hover.png;Stretch;0;",
                                     };
        state_operation_panel.operation_cloud_btn_background_[ierd_tgp.game_library.GAME_STATE_NOT_INSTALLED] = {
                                        background = "ONEIMAGE:bottom_bar\\with_menu\\download_normal.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\with_menu\\download_hover.png;Stretch;0;",
                                     };
        state_operation_panel.operation_cloud_btn_background_[ierd_tgp.game_library.GAME_STATE_DOWNLOADED] = {
                                        background = "ONEIMAGE:bottom_bar\\with_menu\\install_normal.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\with_menu\\install_hover.png;Stretch;0;",
                                     };
        state_operation_panel.operation_cloud_btn_background_[ierd_tgp.game_library.GAME_STATE_DOWNLOAD_FAIL] = {
                                        background = "ONEIMAGE:bottom_bar\\with_menu\\re_download_normal.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\with_menu\\re_download_hover.png;Stretch;0;",
                                     };
        state_operation_panel.operation_cloud_btn_background_[ierd_tgp.game_library.GAME_STATE_BROKEN] = {
                                        background = "ONEIMAGE:bottom_bar\\with_menu\\re_download_normal.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\with_menu\\re_download_hover.png;Stretch;0;",
                                     };
        state_operation_panel.operation_cloud_btn_background_[25] = {
                                        background = "ONEIMAGE:bottom_bar\\with_menu\\update_plugin_normal.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\with_menu\\update_plugin_hover.png;Stretch;0;",
                                     };
                                     
        -- state button
        state_operation_panel.state_btn_background_[ierd_tgp.game_library.GAME_STATE_NORMAL] = {
                                        background = "ONEIMAGE:bottom_bar\\more_normal.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\more_hover.png;Stretch;0",
                                        background_pressed = "ONEIMAGE:bottom_bar\\more_normal.png;Stretch;0",
        };
        state_operation_panel.state_btn_background_[ierd_tgp.game_library.GAME_STATE_NEED_UPDATE] = {
                                        background = "ONEIMAGE:bottom_bar\\more_normal_green.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\more_hover_green.png;Stretch;0;",
                                        background_pressed = "ONEIMAGE:bottom_bar\\more_normal_green.png;Stretch;0",
                                     };
        state_operation_panel.state_btn_background_[ierd_tgp.game_library.GAME_STATE_UPDATE_FAIL] = {
                                        background = "ONEIMAGE:bottom_bar\\more_normal_green.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\more_hover_green.png;Stretch;0;",
                                        background_pressed = "ONEIMAGE:bottom_bar\\more_normal_green.png;Stretch;0",
                                     };
        state_operation_panel.state_btn_background_[ierd_tgp.game_library.GAME_STATE_NOT_INSTALLED] = {
                                        background = "ONEIMAGE:bottom_bar\\more_normal_blue.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\more_hover_blue.png;Stretch;0;",
                                        background_pressed = "ONEIMAGE:bottom_bar\\more_normal_blue.png;Stretch;0",
                                     };
        state_operation_panel.state_btn_background_[ierd_tgp.game_library.GAME_STATE_DOWNLOADED] = {
                                        background = "ONEIMAGE:bottom_bar\\more_normal_blue.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\more_hover_blue.png;Stretch;0;",
                                        background_pressed = "ONEIMAGE:bottom_bar\\more_normal_blue.png;Stretch;0",
                                     };
        state_operation_panel.state_btn_background_[ierd_tgp.game_library.GAME_STATE_DOWNLOAD_FAIL] = {
                                        background = "ONEIMAGE:bottom_bar\\more_normal_blue.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\more_hover_blue.png;Stretch;0;",
                                        background_pressed = "ONEIMAGE:bottom_bar\\more_normal_blue.png;Stretch;0",
                                     };
        state_operation_panel.state_btn_background_[ierd_tgp.game_library.GAME_STATE_BROKEN] = {
                                        background = "ONEIMAGE:bottom_bar\\more_normal_blue.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\more_hover_blue.png;Stretch;0;",
                                        background_pressed = "ONEIMAGE:bottom_bar\\more_normal_blue.png;Stretch;0",
                                     };
        state_operation_panel.state_btn_background_[25] = {
                                        background = "ONEIMAGE:bottom_bar\\more_normal_green.png;Stretch;0;",
                                        background_hover = "ONEIMAGE:bottom_bar\\more_hover_green.png;Stretch;0;",
                                        background_pressed = "ONEIMAGE:bottom_bar\\more_normal_green.png;Stretch;0",
                                     };
        state_operation_panel.operation_btn_using_background_ = state_operation_panel.operation_btn_background_;

        comm_center.listen_broadcast("Msg_RailHost_NotifyRailDlcUpdatingInfo",
                                     "state_operation_panel.on_dlc_update_msg");
    end;

    on_dlc_update_msg = function(msg)
        if msg == nil or msg.param == nil then
            return;
        end
        if state_operation_panel.cur_game_state_ ~= ierd_tgp.game_library.GAME_STATE_UPDATING or
            state_operation_panel.cur_game_sub_state_ ~= ierd_tgp.game_library.GAME_UPDATE_DLC_UPDATING then
            return;
        end

        local param = base_utility.json_to_table(msg.param);
        if param == nil or param.download_dlc_list == nil then
            return;
        end

        local updating_dlc = nil;
        local download_paused_dlc = nil;
        local failed_dlc = nil;
        for i, dlc in pairs(param.download_dlc_list) do
            if dlc.game_id == tostring(state_operation_panel.cur_game_id_) then
                if dlc.dlc_state == dlcState.Updating or dlc.dlc_state == dlcState.Downloading or
                        dlc.dlc_state == dlcState.DownloadOk or dlc.dlc_state == dlcState.Installing or 
                        dlc.dlc_state == dlcState.WaitingForInstall then
                    updating_dlc = dlc;
                    break;
                elseif dlc.dlc_state == dlcState.DownloadingPause then
                    if dlc.has_next_download_dlc == 1 then
                        break;
                    end
                    if download_paused_dlc == nil then
                        download_paused_dlc = dlc;
                    end
                elseif dlc.dlc_state == dlcState.DownloadFailed or dlc.dlc_state >= dlcState.InstalledFailed  then
                    if failed_dlc == nil then
                        failed_dlc = dlc;
                    end
                end
            end
        end;
        if updating_dlc ~= nil then
            state_operation_panel.cur_updating_dlc_id_ = tonumber(updating_dlc.dlc_id);
            state_operation_panel.cur_dlc_state_ = updating_dlc.dlc_state;
            state_operation_panel.show_dlc_updating_state(updating_dlc);
        elseif download_paused_dlc ~= nil then
            state_operation_panel.cur_updating_dlc_id_ = tonumber(download_paused_dlc.dlc_id);
            state_operation_panel.cur_dlc_state_ = download_paused_dlc.dlc_state;
            state_operation_panel.show_dlc_pause_state(download_paused_dlc);
        elseif failed_dlc ~= nil then
            state_operation_panel.cur_updating_dlc_id_ = 0;
            state_operation_panel.cur_dlc_state_ = failed_dlc.dlc_state;
            state_operation_panel.show_dlc_error_state(failed_dlc);
        end
        base_utility.log("[state_operation_panel]on_dlc_update_msg, msg="..msg.param..",cur_dlc="..
            state_operation_panel.cur_updating_dlc_id_);
    end;

    show_dlc_updating_state = function(dlc_info)
        local progress = 0;
        local total_size = tonumber(dlc_info.total_size);
        local finished_size = tonumber(dlc_info.finished_size);
        if total_size ~= 0 then
            progress = finished_size * 100 / total_size;
        end

        local status_txt = "";
        if dlc_info.dlc_state == dlcState.Updating or dlc_info.dlc_state == dlcState.Downloading then
            status_txt = string.format("%s：%s %.2f%%", dlc_info.name, LoadStr(ID_BA_DOWNLOADING), progress);
        elseif dlc_info.dlc_state == dlcState.DownloadOk then
            status_txt = string.format("%s：%s", dlc_info.name, LoadStr(ID_BA_DOWNFINISH));
        elseif dlc_info.dlc_state == dlcState.Installing then
            status_txt = string.format("%s：%s", dlc_info.name, LoadStr(ID_BA_INSTALLING));
        elseif dlc_info.dlc_state == dlcState.WaitingForInstall then
            status_txt = string.format("%s：%s", dlc_info.name, LoadStr(ID_BT_WAITDOWNLOAD));
        end
        local speed_txt = nil;
        ui_utility.setproperty_by_id(frame_bottom_view.bottom_server_info_ctn_id_, "Visible", "false"); 
        ui_utility.setproperty_by_id(frame_bottom_view.bottom_branch_info_ctn_id_, "Visible", "false");
        state_operation_panel.set_progress_info_helper(progress, status_txt, speed_txt);

        local updating_downing_cnt_id = ui_utility.get_ctrl_id_by_path(frame_bottom_view.status_operation_id_, "UpdatingOrDowningCnt");
        ui_utility.setproperty_by_id(updating_downing_cnt_id, "Visible", "true");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_right", "Visible", "true");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "Visible", "true");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "Background", 
            "ONEIMAGE:bottom_bar\\stop.png;Stretch;0;");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "BackgroundHover", 
            "ONEIMAGE:bottom_bar\\stop_hover.png;Stretch;0;");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "BackgroundPressed", 
            "ONEIMAGE:bottom_bar\\stop.png;Stretch;0;");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "TextTip",
            LoadStr(ID_SUSPEND));
        base_utility.log("[state_operation_panel]show_dlc_updating_state, dlc_id="..dlc_info.dlc_id);
    end;

    show_dlc_pause_state = function(dlc_info)
        local progress = 0;
        local total_size = tonumber(dlc_info.total_size);
        local finished_size = tonumber(dlc_info.finished_size);
        if total_size ~= 0 then
            progress = finished_size * 100 / total_size;
        end

        local status_txt = string.format("%s：%s %.2f%%", dlc_info.name, LoadStr(ID_BA_DOWNLOADPAUSE), progress);
        local speed_txt = nil;
        ui_utility.setproperty_by_id(frame_bottom_view.bottom_server_info_ctn_id_, "Visible", "false"); 
        ui_utility.setproperty_by_id(frame_bottom_view.bottom_branch_info_ctn_id_, "Visible", "false");
        state_operation_panel.set_progress_info_helper(progress, status_txt, speed_txt);

        local updating_downing_cnt_id = ui_utility.get_ctrl_id_by_path(frame_bottom_view.status_operation_id_, "UpdatingOrDowningCnt");
        ui_utility.setproperty_by_id(updating_downing_cnt_id, "Visible", "true");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_right", "Visible", "true");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "Visible", "true");

        -- 设置继续的背景图
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "Background", 
            "ONEIMAGE:bottom_bar\\play.png;Stretch;0;");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "BackgroundHover", 
            "ONEIMAGE:bottom_bar\\play_hover.png;Stretch;0;");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "BackgroundPressed", 
            "ONEIMAGE:bottom_bar\\play.png;Stretch;0;");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "TextTip",
            LoadStr(ID_CONTINUE));
        base_utility.log("[state_operation_panel]show_dlc_pause_state, dlc_id="..dlc_info.dlc_id);
    end;

    show_dlc_error_state = function(dlc_info)
        local status_txt = string.format("%s: %s", dlc_info.name, LoadStr(ID_BA_UPDATEFAIL));
        state_operation_panel.set_error_prompt_txt(status_txt);
        base_utility.log("[state_operation_panel]show_dlc_error_state, dlc_id="..dlc_info.dlc_id);
    end;

    -- 显示游戏的状态和文本
    show_game_status_text = function(game_state_param)
        if game_state_param == nil then return end
        ierd_tgp.tpf_ui.Log("[state_operation_panel]show_game_status_text. game_id:"
            .. tostring(game_state_param.game_id) ..",is_cloud_game:"
            .. tostring(game_state_param.is_cloud_game) .. ",game_state:" .. game_state_param.status
            .. ",sub_state:" .. game_state_param.sub_status);
        state_operation_panel.is_cloud_game_ = game_state_param.is_cloud_game;
        local game_id = game_state_param.game_id;
        state_operation_panel.cur_game_id_ = game_id;
        local state_value = game_state_param.status;
        state_operation_panel.cur_game_state_ = state_value;
        local sub_state_value = game_state_param.sub_status;
        state_operation_panel.cur_game_sub_state_ = sub_state_value;
        local fSpeed = game_state_param.speed;
        local fProcess = game_state_param.progress;
        local fRemain_time = game_state_param.left_time;
        local errMsg = game_state_param.msg;
        local support_silent_install = game_state_param.silent_install;
        local install_mode = game_state_param.install_mode;
        local show_detail = false;
        if state_operation_panel.is_cloud_game_ then
            state_operation_panel.operation_btn_using_background_ = state_operation_panel.operation_cloud_btn_background_;
        else 
            state_operation_panel.operation_btn_using_background_ = state_operation_panel.operation_btn_background_;
        end;
        
        -- 设置（取消）相应的互斥量
        state_operation_panel.set_operation_game_for_other_helper(game_id, state_value);

        if ierd_tgp.game_library.GAME_STATE_NORMAL == state_value or 
            ierd_tgp.game_library.GAME_STATE_UNKNOWN == state_value then
             state_operation_panel.set_start_update_status(LoadStr(ID_PL_STARTGAME), ierd_tgp.game_library.GAME_STATE_NORMAL);
        elseif ierd_tgp.game_library.GAME_STATE_LAUNCHING == state_value then
            local background = "ONEIMAGE:bottom_bar\\starting.png;Stretch;0;";
            if state_operation_panel.is_cloud_game_ == true then
                background = "ONEIMAGE:bottom_bar\\with_menu\\starting.png;Stretch;0;";
            end
            state_operation_panel.set_status_text_helper(state_value, background);
            state_operation_panel.refresh_normal_state_menu_btn_bg();
        elseif ierd_tgp.game_library.GAME_STATE_RUNNING == state_value then
            -- 设置游戏菜单可见
            local background = "ONEIMAGE:bottom_bar\\running.png;Stretch;0;";
            if state_operation_panel.is_cloud_game_ == true then
                background = "ONEIMAGE:bottom_bar\\with_menu\\running.png;Stretch;0;";
            end
            state_operation_panel.set_status_text_helper(state_value, background);
            state_operation_panel.refresh_normal_state_menu_btn_bg();
        elseif ierd_tgp.game_library.GAME_STATE_SERVER_UNAVAILABLE == state_value then
            local background = "ONEIMAGE:bottom_bar\\mainting.png;Stretch;0;";
            if state_operation_panel.is_cloud_game_ == true then
                background = "ONEIMAGE:bottom_bar\\with_menu\\mainting.png;Stretch;0;";
            end
            state_operation_panel.set_status_text_helper(state_value, background);
            state_operation_panel.refresh_normal_state_menu_btn_bg();
        elseif ierd_tgp.game_library.GAME_STATE_UNINSTALLING == state_value then
            local background = "ONEIMAGE:bottom_bar\\uninstalling.png;Stretch;0;";
            if state_operation_panel.is_cloud_game_ == true then
                background = "ONEIMAGE:bottom_bar\\with_menu\\uninstalling.png;Stretch;0;";
            end
            state_operation_panel.set_status_text_helper(state_value, background);
            state_operation_panel.refresh_normal_state_menu_btn_bg();
        elseif ierd_tgp.game_library.GAME_STATE_NEED_UPDATE == state_value then
            local pause_status = 0;
            local update_progress = 0;
            if sub_state_value ~= ierd_tgp.game_library.GAME_UPDATE_DLC_NEED_UPDATE then
                pause_status, update_progress = frame_bottom_model.get_game_update_pause_status(game_id);
            end
            local is_switch_branch_game = state_operation_panel.is_game_last_action_switch_branch(game_id);
            if 0 ~= pause_status then
                if fProcess < update_progress then
                   fProcess = update_progress;
                end
                local status_txt = string.format("%s %.2f%%", LoadStr(ID_UPDATE_PAUSED), fProcess);
                state_operation_panel.set_update_pause_status(game_id, status_txt, fProcess);   
            else
                state_operation_panel.set_start_update_status(LoadStr(ID_BA_UPDATEGAME), state_value);
            end
        elseif ierd_tgp.game_library.GAME_STATE_BROKEN == state_value then
            if sub_state_value == 1 then  -- 支持重新下载
                state_operation_panel.set_error_prompt_txt(LoadStr(ID_BT_GAME_INVALID_VER), ierd_tgp.game_library.GAME_STATE_BROKEN);
            else
                state_operation_panel.set_error_prompt_txt(LoadStr(ID_BT_GAME_NOTSUPPORT));
                state_operation_panel.set_inaccessible_download_btn_status();
            end
        elseif ierd_tgp.game_library.GAME_STATE_UPDATE_FAIL == state_value then
            local msgText = LoadStr(ID_BT_GAME_UPDATEFAIL);
            if errMsg ~= nil and errMsg ~= "" then
                msgText = errMsg;
            end
            state_operation_panel.set_error_prompt_txt(msgText, ierd_tgp.game_library.GAME_STATE_UPDATE_FAIL);
        elseif ierd_tgp.game_library.GAME_STATE_NOT_INSTALLED == state_value then
            state_operation_panel.set_start_update_status(LoadStr(ID_BA_DOWNLOADGAME), state_value);
        elseif ierd_tgp.game_library.GAME_STATE_DOWNLOADED == state_value then
            -- 下载完成，显示助手区域
            ierd_tgp.tpf_ui.Log("[frame_bottom_view]download complete.");     
            --state_operation_panel.set_helper_state(game_state_param.game_id);
            gift_op_panel.hide_gift_icon();
            state_operation_panel.set_error_prompt_txt(LoadStr(ID_BT_DOWNLAOD_DONE), state_value);
            state_operation_panel.notify_page_download_complete(game_state_param.game_id);
        elseif ierd_tgp.game_library.GAME_STATE_DOWNLOAD_FAIL == state_value then
            local msgText = LoadStr(ID_BT_DOWNLOADFAIL);
            if errMsg ~= nil and errMsg ~= "" then
                msgText = errMsg;
            end
            state_operation_panel.set_error_prompt_txt(msgText, state_value);
        elseif ierd_tgp.game_library.GAME_STATE_INSTALLING == state_value then  -- 安装中
            state_operation_panel.set_installing_status(game_id, fProcess, support_silent_install, install_mode, game_state_param.custom_text);
        elseif ierd_tgp.game_library.GAME_STATE_SELECTING_SERVER == state_value then
            local background = "ONEIMAGE:bottom_bar\\choose_zone.png;Stretch;0;";
            if state_operation_panel.is_cloud_game_ == true then
                background = "ONEIMAGE:bottom_bar\\with_menu\\choose_zone.png;Stretch;0;";
            end
            state_operation_panel.set_status_text_helper(state_value, background);
            state_operation_panel.refresh_normal_state_menu_btn_bg();
        elseif ierd_tgp.game_library.GAME_STATE_DOWNLOADING == state_value then  -- 下载中
            -- 设置进度文本
            local status_txt = '';
            local time_left = '';
            local use_tinysetup = frame_bottom_model.get_game_install_mode(game_id);
            if use_tinysetup == 1 then
                show_detail, status_txt, time_left = state_operation_panel.get_tinysetup_downloading_status_text(sub_state_value, fProcess);
            else
                status_txt = state_operation_panel.get_downloading_status_text(sub_state_value, fProcess);
            end
            
            -- 设置速度和剩余时间
            local speed_txt = state_operation_panel.get_speed_remain_time(fSpeed, fRemain_time);
            if ierd_tgp.game_library.GAME_DOWNLOAD_WAIT == sub_state_value or 
                ierd_tgp.game_library.GAME_DOWNLOAD_INIT == sub_state_value then
                -- 等待下载状态不显示速度和时间
                speed_txt = "";
            end
            if show_detail then
                -- 显示详细状态不显示速度和时间
               speed_txt = "";
            end

            -- 优先显示下载器算出的倒计时
            if time_left ~= nil and time_left ~= "" then
                if fSpeed ~= nil and 0 ~= fSpeed then
                    speed_txt = string.format("%s", state_operation_panel.format_speed(fSpeed));
                end
                speed_txt = string.format("%s   %s", speed_txt,
                    time_left);
            end
            state_operation_panel.set_downloading_status(fProcess, status_txt, speed_txt, game_id);
        elseif ierd_tgp.game_library.GAME_STATE_DOWNLOAD_PAUSED == state_value then
            local status_txt = string.format("%s %.2f%%", LoadStr("FRAME_BOTTOM_DOWNLOADPAUSE"),
                fProcess);
            state_operation_panel.set_download_pause_status(game_id, status_txt, fProcess);
        elseif ierd_tgp.game_library.GAME_STATE_UPDATING == state_value then  -- 正在更新
            if sub_state_value == ierd_tgp.game_library.GAME_UPDATE_DLC_UPDATING then
                -- dlc更新通过on_dlc_update_msg来更新状态
                local param = {};
                param['game_id'] = game_id;
                param['exist'] = false;
                param['dlc_info'] = '';
                local ret = comm_center.call_service("Svr_RailHost_GetCurUpdatingDlcInfo", param);
                if ret ~= nil and ret.exist then
                    state_operation_panel.on_dlc_update_msg({param = ret.dlc_info});
                end
                return;
            end
            -- 设置进度文本
            local patch_name = "";
            if nil ~= game_state_param.cur_patch_name then
                patch_name = game_state_param.cur_patch_name;
                if state_operation_panel.is_english_ver then 
                    if string.len(patch_name) > 6 then
                        patch_name = " " .. string.sub(patch_name, 0, 6);
                    end
                else
                if string.len(patch_name) > 7 then
                    patch_name = string.sub(patch_name, 0, 7);
                end
            end
            end
            local pause_status = 0;
            local update_progress = 0;
            pause_status, update_progress = frame_bottom_model.get_game_update_pause_status(game_id);
            local show_progress = fProcess;
            if 0 ~= pause_status then
                if fProcess < update_progress then
                    show_progress = update_progress;
                end
            end

            base_utility.log(string.format("[show_game_status_text]fprocess:%d, show_progress:%d, update_progress:%d", fProcess, show_progress, update_progress));

            local show_detail = false;
            local status_txt = state_operation_panel.get_updating_status_text(sub_state_value, show_progress, patch_name);
            local time_left = "";

            local external_update = state_operation_panel.is_external_update(game_id);
            if external_update == 1 then
                status_txt = state_operation_panel.get_external_updating_status_text(sub_state_value, show_progress, patch_name);
            end

            if ierd_tgp.game_library.GAME_UPDATE_DEPOT_INIT == sub_state_value or 
               ierd_tgp.game_library.GAME_UPDATE_DEPOT_WAIT == sub_state_value or
               ierd_tgp.game_library.GAME_UPDATE_DEPOT_DOWNLOAD == sub_state_value or
               ierd_tgp.game_library.GAME_UPDATE_DEPOT_INSTALL == sub_state_value then
                show_detail, status_txt, time_left = state_operation_panel.get_tinysetup_updating_status_text(sub_state_value, show_progress);
            end
            -- 设置速度和剩余时间
            local speed_txt = state_operation_panel.get_speed_remain_time(fSpeed, fRemain_time);
            if ierd_tgp.game_library.GAME_UPDATE_DOWNLOAD ~= sub_state_value and 
               ierd_tgp.game_library.GAME_UPDATE_DEPOT_DOWNLOAD ~= sub_state_value then
                -- 非下载的场景下都不显示速度
                speed_txt = "";
            end
            if show_detail then
                -- 显示详细信息的场景下都不显示速度
                speed_txt = "";
            end

            -- 优先显示下载器算出的倒计时
            if time_left ~= nil and time_left ~= "" then
                if fSpeed ~= nil and 0 ~= fSpeed then
                    speed_txt = string.format("%s", state_operation_panel.format_speed(fSpeed));
                end
                speed_txt = string.format("%s   %s", speed_txt,
                    time_left);
            end

            state_operation_panel.set_updating_status(show_progress, status_txt, speed_txt,
                game_id);
        end;
    end;
    get_updating_status_text = function(sub_state_value, fProcess, patch_name)
        local status_txt = "";
        if ierd_tgp.game_library.GAME_UPDATE_INIT == sub_state_value or 
           ierd_tgp.game_library.GAME_UPDATE_DOWNLOAD_LIST == sub_state_value or
           ierd_tgp.game_library.GAME_UPDATE_VERIFY == sub_state_value then
            -- 更新初始化（6）、下载版本列表（1）、校验文件（2）都作为初始化显示
            status_txt = string.format("%s %.2f%%", LoadStr("FRAME_BOTTOM_PROGRESS_INIT"), fProcess);
        elseif ierd_tgp.game_library.GAME_UPDATE_WAIT == sub_state_value then
            status_txt = LoadStr("FRAME_BOTTOM_UPDATE_WAITTING");
        elseif ierd_tgp.game_library.GAME_UPDATE_DOWNLOAD == sub_state_value then
            -- 下载
            local name_tips = string.format(LoadStr("FRAME_BOTTOM_UPDATE_DOWNLOADING"), patch_name);
            if nil == fProcess then
                status_txt = name_tips;
            else
                local progress_text = state_operation_panel.get_progress_info_text(fProcess);
                status_txt = string.format("%s %s", name_tips, progress_text);
            end
        elseif ierd_tgp.game_library.GAME_UPDATE_INSTALL == sub_state_value then
            -- 安装
            local name_tips = string.format(LoadStr("FRAME_BOTTOM_UPDATE_INSTALL"), patch_name);
            if nil == fProcess then
                status_txt = name_tips;
            else
                status_txt = string.format("%s %.2f%%", name_tips, fProcess);
            end
        end
        return status_txt;
    end;

    get_tinysetup_updating_status_text = function(sub_state_value, fProcess)
        local show_detail = false;
        local status_txt = "";
        local time_left = "";
        
        local progress_txt = string.format("%.2f%%", fProcess);
        local param = {};
        param['progress'] = progress_txt;
        param['detail_txt'] = '';
        param['time_left'] = '';
        local ret = comm_center.call_service('i_service_tinydl_getprogress_detail', param);
        local show_txt = "";
        if ret ~= nil and ret.detail_txt ~= nil then
            show_txt = ret.detail_txt;
        end

        if ret ~= nil and ret.time_left ~= nil then
            time_left = ret.time_left;
        end

        if ierd_tgp.game_library.GAME_UPDATE_DEPOT_WAIT == sub_state_value then
            status_txt = LoadStr("FRAME_BOTTOM_UPDATE_WAITTING");
        elseif ierd_tgp.game_library.GAME_UPDATE_DEPOT_INIT == sub_state_value then
            status_txt = string.format("%s%s %.2f%%", LoadStr("FRAME_BOTTOM_PROGRESS_INIT"),
                show_txt, fProcess);
        else
            if fProcess == nil then
                status_txt = LoadStr(ID_BT_UPDATING);
            else
                if (show_txt == '') then
                    local progress_text = state_operation_panel.get_progress_info_text(fProcess);
                    status_txt = string.format("%s%s %s", LoadStr(ID_BT_UPDATING),
                        show_txt, progress_text);
                else
                    status_txt = string.format("%s", show_txt);
                    show_detail = true;
                end
            end
        end
        return show_detail, status_txt, time_left;
    end;

    get_external_updating_status_text = function(sub_state_value, fProcess, patch_name)
        local status_txt = "";
        if 0 == sub_state_value then
            status_txt = string.format("%s %.2f%%", LoadStr("FRAME_BOTTOM_PROGRESS_INIT"), fProcess);
        elseif ierd_tgp.game_library.GAME_UPDATE_WAIT == sub_state_value then
            status_txt = LoadStr("FRAME_BOTTOM_UPDATE_WAITTING");
        elseif ierd_tgp.game_library.GAME_UPDATE_DOWNLOAD == sub_state_value then
            -- 下载
            local name_tips = string.format(LoadStr("FRAME_BOTTOM_UPDATE_DOWNLOADING"), patch_name);
            if nil == fProcess then
                status_txt = name_tips;
            else
                local progress_text = state_operation_panel.get_progress_info_text(fProcess);
                status_txt = string.format("%s %s", name_tips, progress_text);
            end
        elseif ierd_tgp.game_library.GAME_UPDATE_INSTALL == sub_state_value then
            -- 安装
            local name_tips = string.format(LoadStr("FRAME_BOTTOM_UPDATE_INSTALL"), patch_name);
            if nil == fProcess then
                status_txt = name_tips;
            else
                status_txt = string.format("%s %.2f%%", name_tips, fProcess);
            end
        end
        return status_txt;
    end;

    get_downloading_status_text = function(sub_state_value, fProcess)
        local status_txt = "";
        
        local ret = comm_center.call_service('i_service_dl_getprogress_detail');
        local show_txt = "";
        if ret ~= nil and ret.detail_txt ~= nil then
            show_txt = ret.detail_txt;
        end

        if ierd_tgp.game_library.GAME_DOWNLOAD_WAIT == sub_state_value then
            status_txt = LoadStr("FRAME_BOTTOM_DN_WAITTING")..show_txt;
        elseif ierd_tgp.game_library.GAME_DOWNLOAD_INIT == sub_state_value then
            
            status_txt = string.format("%s%s %.2f%%", LoadStr("FRAME_BOTTOM_PROGRESS_INIT"), show_txt, fProcess);
        else
            if fProcess == nil then
                status_txt = LoadStr(ID_BT_DOWNLOADING);
            else
                local progress_text = state_operation_panel.get_progress_info_text(fProcess);
                status_txt = string.format("%s%s %s", LoadStr(ID_BT_DOWNLOADING), show_txt, progress_text);
            end
        end
        return status_txt;
    end;
    get_tinysetup_downloading_status_text = function(sub_state_value, fProcess)
        local show_detail = false;
        local status_txt = "";
        local time_left = "";

        local progress_txt = string.format("%.2f%%", fProcess);
        local param = {};
        param['progress'] = progress_txt;
        param['detail_txt'] = '';
        param['time_left'] = '';
        local ret = comm_center.call_service('i_service_tinydl_getprogress_detail', param);
        local show_txt = "";
        if ret ~= nil and ret.detail_txt ~= nil then
            show_txt = ret.detail_txt;
        end

        if ret ~= nil and ret.time_left ~= nil then
            time_left = ret.time_left;
        end

        if ierd_tgp.game_library.GAME_DOWNLOAD_WAIT == sub_state_value then
            status_txt = LoadStr("FRAME_BOTTOM_DN_WAITTING");
        elseif ierd_tgp.game_library.GAME_DOWNLOAD_INIT == sub_state_value then
            
            status_txt = string.format("%s %.2f%%", LoadStr("FRAME_BOTTOM_PROGRESS_INIT"), fProcess);
        else
            if fProcess == nil then
                status_txt = LoadStr(ID_BT_DOWNLOADING);
            else
                if (show_txt == '') then
                    local progress_text = state_operation_panel.get_progress_info_text(fProcess);
                    status_txt = string.format("%s%s %s", LoadStr(ID_BT_DOWNLOADING), show_txt, progress_text);
                else
                    status_txt = string.format("%s", show_txt);
                    show_detail = true;
                end
            end
        end
        return show_detail, status_txt, time_left;
    end;
    get_speed_remain_time = function(fSpeed, fRemain_time)
        local speed_txt = "";
        if fSpeed ~= nil and 0 ~= fSpeed then
            speed_txt = string.format("%s", state_operation_panel.format_speed(fSpeed));
        end
        if fRemain_time ~= nil then
            speed_txt = string.format("%s   %s", speed_txt,
                state_operation_panel.format_remain_time(fRemain_time));
        end
        return speed_txt;
    end;
    -- 设置开始和更新的按钮状态
    set_start_update_status = function(op_btn_text, game_state)
        ui_utility.setproperty_by_path(frame_bottom_view.status_operation_id_, "UpdatingOrDowningCnt", "Visible", "false"); 
        ui_utility.setproperty_by_id(frame_bottom_view.bottom_server_info_ctn_id_, "Visible", "true");
        ui_utility.setproperty_by_id(frame_bottom_view.bottom_branch_info_ctn_id_, "Visible", "true");
        local state_op_ctn_id = ui_utility.get_ctrl_id_by_path(frame_bottom_view.status_operation_id_, "StateOperationCnt");
        ui_utility.setproperty_by_id(state_op_ctn_id, "Visible", "true");
        ui_utility.setproperty_by_path(state_op_ctn_id, "StateBtn", "Visible", "false");
        ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn", "Visible", "true");
            
        local normal_img = state_operation_panel.operation_btn_using_background_[game_state].background;
        local hover_img = state_operation_panel.operation_btn_using_background_[game_state].background_hover;
        local press_img = state_operation_panel.operation_btn_using_background_[game_state].background;
        ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn", "Background", normal_img);
        ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn", "BackgroundHover", hover_img);
        ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn", "BackgroundPressed", press_img);

        ui_utility.setproperty_by_path(state_op_ctn_id, "error_prompt_cnt", "Visible", "false");   
        state_operation_panel.refresh_normal_state_bg(game_state);
        
        if state_operation_panel.is_cloud_game_ then
            ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn\\GameMenuBtn", "Visible", "true");
        
            local state_btn_normal_img = state_operation_panel.state_btn_background_[game_state].background;
            local state_btn_hover_img = state_operation_panel.state_btn_background_[game_state].background_hover;
            local state_btn_press_img = state_operation_panel.state_btn_background_[game_state].background_pressed;
            ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn\\GameMenuBtn", "Background", state_btn_normal_img);
            ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn\\GameMenuBtn", "BackgroundHover", state_btn_normal_img);
            ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn\\GameMenuBtn", "BackgroundPressed", state_btn_press_img);
        else
            ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn\\GameMenuBtn", "Visible", "false");
            ui_utility.setproperty_by_path(state_op_ctn_id, "StateBtn\\GameMenuBtn", "Visible", "false");
        end
    end;

    set_status_text_helper = function(game_state, background)
        ui_utility.setproperty_by_path(frame_bottom_view.status_operation_id_, "UpdatingOrDowningCnt", "Visible", "false"); 
        ui_utility.setproperty_by_id(frame_bottom_view.bottom_server_info_ctn_id_, "Visible", "true");
        ui_utility.setproperty_by_id(frame_bottom_view.bottom_branch_info_ctn_id_, "Visible", "true");
        local state_op_ctn_id = ui_utility.get_ctrl_id_by_path(frame_bottom_view.status_operation_id_, "StateOperationCnt");
        ui_utility.setproperty_by_id(state_op_ctn_id, "Visible", "true");
        ui_utility.setproperty_by_path(state_op_ctn_id, "StateBtn", "Visible", "true");
        ui_utility.setproperty_by_path(state_op_ctn_id, "error_prompt_cnt", "Visible", "false");
        ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn", "Visible", "false");
        ui_utility.setproperty_by_path(state_op_ctn_id, "StateBtn", "Background", background);
        if game_state == ierd_tgp.game_library.GAME_STATE_RUNNING then
            ui_utility.setproperty_by_path(state_op_ctn_id, "StateBtn\\GameMenuBtn", "Visible", "true");
        else
            ui_utility.setproperty_by_path(state_op_ctn_id, "StateBtn\\GameMenuBtn", "Visible", "false");
        end
    end;
    set_updating_status = function(fProcess, status_txt, speed_txt, game_id)
        state_operation_panel.set_progress_info_helper(fProcess, status_txt, speed_txt);
        local updating_downing_cnt_id = ui_utility.get_ctrl_id_by_path(frame_bottom_view.status_operation_id_, "UpdatingOrDowningCnt");

        -- jameszhai: 天刀不显示更新取消按钮
        local   zParam = {};

        zParam["game_id"] = game_id;

        local zTemp = comm_center.call_service("Svr_GetHideCancelUpdate", zParam);
        local bTemp = (nil ~= zTemp["need_hide"]) and (0 ~= zTemp["need_hide"]);

        if bTemp then
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_right", "Visible", "false");
        else
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_right", "Visible", "true");
        end;

        -- 外部第三方更新方式
        local external_update = state_operation_panel.is_external_update(game_id);

        -- 设置左边暂停背景图
        -- 如果是多分支版本 或 第三方更新方式，则不显示暂停按钮
        local is_switch_branch_game = state_operation_panel.is_game_last_action_switch_branch(game_id);
        if is_switch_branch_game == 1 or external_update == 1 then
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "Visible", "false");
        else
            if bTemp then
                ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "Visible", "false");
            else
                ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "Visible", "true");
            end;

            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "Background", 
                "ONEIMAGE:bottom_bar\\stop.png;Stretch;0;");
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "BackgroundHover", 
                "ONEIMAGE:bottom_bar\\stop_hover.png;Stretch;0;");
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "BackgroundPressed", 
                "ONEIMAGE:bottom_bar\\stop.png;Stretch;0;");
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "TextTip",
                LoadStr(ID_SUSPEND));
        end

        -- 显示礼包
        local show_download_gift = frame_bottom_model.get_show_download_gift(game_id);
        if show_download_gift then
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_gift", "Visible", "true");
        else
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_gift", "Visible", "false");
        end

    end;
    set_downloading_status = function(fProcess, status_txt, speed_txt, game_id)
        state_operation_panel.set_progress_info_helper(fProcess, status_txt, speed_txt);
        local updating_downing_cnt_id = ui_utility.get_ctrl_id_by_path(frame_bottom_view.status_operation_id_, "UpdatingOrDowningCnt");
        -- 显示下载礼包的icon
        if frame_bottom_view.is_open_gift_download_switch(game_id) then
            -- 判断是否是白名单用户
            if gift_white_list.get_gift_white_list_cfg(game_id) == 1 then
                gift_op_panel.show_gift_icon(updating_downing_cnt_id, game_id);
                gift_op_panel.set_downloading_progress(game_id, fProcess);
            end
       else
           gift_op_panel.hide_gift_icon();
       end
        -- 设置暂停背景图
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "Background", 
            "ONEIMAGE:bottom_bar\\stop.png;Stretch;0;");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "BackgroundHover", 
            "ONEIMAGE:bottom_bar\\stop_hover.png;Stretch;0;");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "BackgroundPressed", 
            "ONEIMAGE:bottom_bar\\stop.png;Stretch;0;");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "TextTip",
            LoadStr(ID_SUSPEND));

        -- jameszhai: 天刀不显示更新取消按钮
        local   zParam = {};

        zParam["game_id"] = game_id;

        local zTemp = comm_center.call_service("Svr_GetHideCancelUpdate", zParam);

        if (nil ~= zTemp["need_hide"]) and (0 ~= zTemp["need_hide"]) then
            -- 设置右边按钮的状态
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "Visible", "false");
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_right", "Visible", "false");
        else
            -- 设置右边按钮的状态
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "Visible", "true");
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_right", "Visible", "true");
        end;

        -- 显示礼包
        local show_download_gift = frame_bottom_model.get_show_download_gift(game_id);
        if show_download_gift then
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_gift", "Visible", "true");
        else
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_gift", "Visible", "false");
        end

    end;
    set_installing_status = function(game_id, fProcess, support_silent_install, install_mode, custom_text)
        local updating_downing_cnt_id = ui_utility.get_ctrl_id_by_path(frame_bottom_view.status_operation_id_, "UpdatingOrDowningCnt");
        -- 安装过程不显示礼包
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_gift", "Visible", "false");
        if support_silent_install == true then
            local status_txt = LoadStr(ID_BT_INSTALLING);
            if fProcess ~= nil then
                local show_progress = fProcess;
                if install_mode == 1 then  -- 支持边下载边安装
                    local game_lib =
                        base_utility.get_component_adapter("IGame_library",
                        "ierd_tgp.game_library.Get_game_library_adapter();");
                    local init_install_progress = 0;
                    if game_lib ~= nil then
                        init_install_progress = game_lib:GetGameInitInstallProgress(game_id);
                    end
                    if fProcess >= init_install_progress and init_install_progress < 100 then
                        local comp_progress = 100 * (fProcess - init_install_progress) / (100 - init_install_progress);
                        if comp_progress >= 0 and comp_progress <= 100 then
                            show_progress = comp_progress;
                        end
                    end
                end      
                local use_tinysetup = frame_bottom_model.get_game_install_mode(game_id);
                if use_tinysetup == 1 then
                    if custom_text ~= nil and custom_text ~= "" then  -- tinysetup 详细安装进度信息
                        status_txt = string.format("%s %.2f%%", 
                            LoadStr(ID_BT_INSTALLING).." "..custom_text, 
                            show_progress);
                    else
                        status_txt = string.format("%s %.2f%%", LoadStr(ID_BT_INSTALLING), show_progress);
                    end
                else
                local blocked_req={};
                blocked_req.game_id = game_id;
                local blocked_state = comm_center.call_service("i_service_game_install_blocked", blocked_req);
                if blocked_state ~= nil and blocked_state.install_blocked == 1 then  -- 安装卡顿，提示用户耐心等待
                    status_txt = string.format("%s %.2f%%", LoadStr("GAME_INSTALLING_BLOCKED"), show_progress);
                else
                    status_txt = string.format("%s %.2f%%", LoadStr(ID_BT_INSTALLING), show_progress);
                end
            end
            end
            state_operation_panel.set_progress_info_helper(fProcess, status_txt, "");
            -- 设置右边按钮的状态
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "Visible", "false");
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_right", "Visible", "false");
        else
            -- 不支持静默安装，隐藏进度条
            local background = "ONEIMAGE:bottom_bar\\installing.png;Stretch;0;";
            if state_operation_panel.is_cloud_game_ == true then
                background = "ONEIMAGE:bottom_bar\\with_menu\\installing.png;Stretch;0;";
            end
            state_operation_panel.set_status_text_helper(
                ierd_tgp.game_library.GAME_STATE_INSTALLING, background);
            state_operation_panel.refresh_normal_state_menu_btn_bg();
        end
    end;
    set_download_pause_status = function(game_id, status_txt, fProcess)
        local state_op_ctn_id = ui_utility.get_ctrl_id_by_path(frame_bottom_view.status_operation_id_, "StateOperationCnt");
        ui_utility.setproperty_by_id(state_op_ctn_id, "Visible", "false");
      
        ui_utility.setproperty_by_id(frame_bottom_view.bottom_server_info_ctn_id_, "Visible", "false"); 
        ui_utility.setproperty_by_id(frame_bottom_view.bottom_branch_info_ctn_id_, "Visible", "false");
        local updating_downing_cnt_id = ui_utility.get_ctrl_id_by_path(frame_bottom_view.status_operation_id_, "UpdatingOrDowningCnt");
        ui_utility.setproperty_by_id(updating_downing_cnt_id, "Visible", "true");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "LvlProgressBarBackground", "Visible", "true");
        local p_lvl_progress_bar = ui_utility.get_ctrl_ptr_by_path(updating_downing_cnt_id, "LvlProgressBarBackground\\LvlProgressBar");
        if p_lvl_progress_bar ~= nil then
            --fixme 九宫格图片在初始时会重叠显示（三宫格在高DPI下有位置偏移）
            -- 当小于某进度时暂时不显示进度图片
            if fProcess < 2 then
                fProcess = 0.0;
            end
            p_lvl_progress_bar:SetPos(fProcess, TRUE);
            local const_image_str = U8toCUIStr(frame_bottom_res.kProgressBarPaused);
            p_lvl_progress_bar:SetLevelTopImage(const_image_str);
            p_lvl_progress_bar:Show(TRUE);
        end
        -- 设置进度文本
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Ctn_Info_Area","Visible", "true");
        local status_txt_id = ui_utility.get_ctrl_id_by_path(updating_downing_cnt_id, "Ctn_Info_Area\\status_txt");
        ui_utility.setproperty_by_id(status_txt_id, "Caption", status_txt);
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Ctn_Info_Area\\speed_txt", "Caption", "");
         -- 显示下载礼包的icon
        if frame_bottom_view.is_open_gift_download_switch(game_id) then
             -- 判断是否是白名单用户
            if gift_white_list.get_gift_white_list_cfg(game_id) == 1 then
                gift_op_panel.show_gift_icon(updating_downing_cnt_id, game_id);
                gift_op_panel.set_downloading_progress(game_id, fProcess);
            end
        else
            gift_op_panel.hide_gift_icon();
        end
        --设置继续的背景图
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "Background", 
            "ONEIMAGE:bottom_bar\\play.png;Stretch;0;");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "BackgroundHover", 
            "ONEIMAGE:bottom_bar\\play_hover.png;Stretch;0;");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "BackgroundPressed", 
            "ONEIMAGE:bottom_bar\\play.png;Stretch;0;");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "TextTip",
            LoadStr(ID_CONTINUE)); 
        -- jameszhai: 天刀不显示更新取消按钮
        local   zParam = {};

        zParam["game_id"] = game_id;

        local zTemp = comm_center.call_service("Svr_GetHideCancelUpdate", zParam);

        if (nil ~= zTemp["need_hide"]) and (0 ~= zTemp["need_hide"]) then
            -- 设置右边按钮的状态
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "Visible", "false");
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_right", "Visible", "false");
        else
            -- 设置右边按钮的状态
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "Visible", "true");
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_right", "Visible", "true");
        end;

        -- 显示礼包
        local show_download_gift = frame_bottom_model.get_show_download_gift(game_id);
        if show_download_gift then
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_gift", "Visible", "true");
        else
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_gift", "Visible", "false");
        end

    end;

    -- 设置更新暂停状态
    set_update_pause_status = function (game_id, status_txt, fProcess)
        local state_op_ctn_id = ui_utility.get_ctrl_id_by_path(frame_bottom_view.status_operation_id_, "StateOperationCnt");
        ui_utility.setproperty_by_id(state_op_ctn_id, "Visible", "false");
       
        ui_utility.setproperty_by_id(frame_bottom_view.bottom_server_info_ctn_id_, "Visible", "false"); 
        ui_utility.setproperty_by_id(frame_bottom_view.bottom_branch_info_ctn_id_, "Visible", "false");
        local updating_downing_cnt_id = ui_utility.get_ctrl_id_by_path(frame_bottom_view.status_operation_id_, "UpdatingOrDowningCnt");
        ui_utility.setproperty_by_id(updating_downing_cnt_id, "Visible", "true");
       
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "LvlProgressBarBackground", "Visible", "true");
        local p_lvl_progress_bar = ui_utility.get_ctrl_ptr_by_path(updating_downing_cnt_id, "LvlProgressBarBackground\\LvlProgressBar");
        if p_lvl_progress_bar ~= nil then
            if fProcess < 2 then
                fProcess = 0.0;
            end
            p_lvl_progress_bar:SetPos(fProcess, TRUE);
            local const_image_str = U8toCUIStr(frame_bottom_res.kProgressBarPaused);
            p_lvl_progress_bar:SetLevelTopImage(const_image_str);
            p_lvl_progress_bar:Show(TRUE);
        end
        -- 设置进度文本
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Ctn_Info_Area", "Visible", "true");
        local status_txt_id = ui_utility.get_ctrl_id_by_path(updating_downing_cnt_id, "Ctn_Info_Area\\status_txt");
        ui_utility.setproperty_by_id(status_txt_id, "Caption", status_txt);
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Ctn_Info_Area\\speed_txt", "Caption", "");

         --设置继续的背景图
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "Background", 
            "ONEIMAGE:bottom_bar\\play.png;Stretch;0;");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "BackgroundHover", 
            "ONEIMAGE:bottom_bar\\play_hover.png;Stretch;0;");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "BackgroundPressed", 
            "ONEIMAGE:bottom_bar\\play.png;Stretch;0;");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "TextTip",
            LoadStr(ID_CONTINUE));       
        -- 设置右边按钮的状态
        -- jameszhai: 天刀不显示更新取消按钮
        local   zParam = {};

        zParam["game_id"] = game_id;

        local zTemp = comm_center.call_service("Svr_GetHideCancelUpdate", zParam);

        if (nil ~= zTemp["need_hide"]) and (0 ~= zTemp["need_hide"]) then
            -- 设置右边按钮的状态
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "Visible", "false");
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_right", "Visible", "false");
        else
            -- 设置右边按钮的状态
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "Visible", "true");
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_right", "Visible", "true");     
        end;

        -- 显示礼包
        local show_download_gift = frame_bottom_model.get_show_download_gift(game_id);
        if show_download_gift then
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_gift", "Visible", "true");
        else
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_gift", "Visible", "false");
        end

    end;
     
    set_progress_info_helper = function(fProcess, status_txt, speed_txt)
        local state_op_ctn_id = ui_utility.get_ctrl_id_by_path(frame_bottom_view.status_operation_id_, "StateOperationCnt");
        ui_utility.setproperty_by_id(state_op_ctn_id, "Visible", "false");
       
        ui_utility.setproperty_by_id(frame_bottom_view.bottom_server_info_ctn_id_, "Visible", "false"); 
        ui_utility.setproperty_by_id(frame_bottom_view.bottom_branch_info_ctn_id_, "Visible", "false");
        local updating_downing_cnt_id = ui_utility.get_ctrl_id_by_path(frame_bottom_view.status_operation_id_, "UpdatingOrDowningCnt");
        local updating_downing_cnt = ui_utility.get_ctrl_ptr_by_path(frame_bottom_view.status_operation_id_, "UpdatingOrDowningCnt");
         -- 通知到dlctips侧
        if updating_downing_cnt ~= nil and updating_downing_cnt:IsVisible() == FALSE then
            base_utility.log("[state_operation_panel][set_progress_info_helper] notify dlc");
        end
        
        ui_utility.setproperty_by_id(updating_downing_cnt_id, "Visible", "true");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "LvlProgressBarBackground", "Visible", "true");
        local p_lvl_progress_bar = ui_utility.get_ctrl_ptr_by_path(updating_downing_cnt_id, "LvlProgressBarBackground\\LvlProgressBar");
        if p_lvl_progress_bar ~= nil then
            if fProcess < 2 then
                fProcess = 0.0;
            end
            p_lvl_progress_bar:SetPos(fProcess, TRUE);
            local image_str = U8toCUIStr(frame_bottom_res.kProgressBarNormal);
            p_lvl_progress_bar:SetLevelTopImage(image_str);
            p_lvl_progress_bar:Show(TRUE);
        end
        -- 设置进度文本
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Ctn_Info_Area", "Visible", "true");
        local status_txt_id = ui_utility.get_ctrl_id_by_path(updating_downing_cnt_id, "Ctn_Info_Area\\status_txt");
        ui_utility.setproperty_by_id(status_txt_id, "Caption", status_txt);
        -- 设置速度和剩余时间
        if speed_txt ~= nil and speed_txt ~= "" then
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Ctn_Info_Area\\speed_txt", "Caption", speed_txt);
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Ctn_Info_Area\\speed_txt", "Visible", "true");
        else
            ui_utility.setproperty_by_path(updating_downing_cnt_id, "Ctn_Info_Area\\speed_txt", "Visible", "false");
        end
    end;
    -- 设置错误提示文本
    set_error_prompt_txt = function(err_prompt_txt, game_state)
        local state_op_ctn_id = ui_utility.get_ctrl_id_by_path(frame_bottom_view.status_operation_id_, "StateOperationCnt");
        ui_utility.setproperty_by_id(state_op_ctn_id, "Visible", "true");
       
        ui_utility.setproperty_by_id(frame_bottom_view.bottom_server_info_ctn_id_, "Visible", "false"); 
        ui_utility.setproperty_by_id(frame_bottom_view.bottom_branch_info_ctn_id_, "Visible", "false");
        local updating_downing_cnt_id = ui_utility.get_ctrl_id_by_path(frame_bottom_view.status_operation_id_, "UpdatingOrDowningCnt");
        ui_utility.setproperty_by_id(updating_downing_cnt_id, "Visible", "false");
        
        ui_utility.setproperty_by_path(state_op_ctn_id, "StateBtn", "Visible", "false");
        ui_utility.setproperty_by_path(state_op_ctn_id, "error_prompt_cnt", "Visible", "true");

        ui_utility.setproperty_by_path(state_op_ctn_id, "error_prompt_cnt\\error_prompt_txt", "ShowTip", "true");
        ui_utility.setproperty_by_path(state_op_ctn_id, "error_prompt_cnt\\error_prompt_txt", "TextTip", err_prompt_txt);
        ui_utility.setproperty_by_path(state_op_ctn_id, "error_prompt_cnt\\error_prompt_txt", "Caption", err_prompt_txt);
        
        if game_state ~= nil then
            ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn", "Visible", "true");
            local normal_img = state_operation_panel.operation_btn_using_background_[game_state].background;
            local hover_img = state_operation_panel.operation_btn_using_background_[game_state].background_hover;
            local press_img = state_operation_panel.operation_btn_using_background_[game_state].background;

            ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn", "Background", normal_img);
            ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn", "BackgroundHover", hover_img);
            ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn", "BackgroundPressed", press_img);
            
            if state_operation_panel.is_cloud_game_ then
                ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn\\GameMenuBtn", "Visible", "true");
                local state_btn_normal_img = state_operation_panel.state_btn_background_[game_state].background;
                local state_btn_hover_img = state_operation_panel.state_btn_background_[game_state].background_hover;
                local state_btn_press_img = state_operation_panel.state_btn_background_[game_state].background_pressed;
                ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn\\GameMenuBtn", "Background", state_btn_normal_img);
                ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn\\GameMenuBtn", "BackgroundHover", state_btn_normal_img);
                ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn\\GameMenuBtn", "BackgroundPressed", state_btn_press_img);
            else 
                ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn\\GameMenuBtn", "Visible", "false");
            end
        else
            ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn", "Visible", "false"); 
        end
    end;

    -- 设置未开放下载时的button状态
    set_inaccessible_download_btn_status = function()
        local state_op_ctn_id = ui_utility.get_ctrl_id_by_path(frame_bottom_view.status_operation_id_, "StateOperationCnt");
        ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn", "Visible", "true");
        local img_bg = "ONEIMAGE:bottom_bar\\inaccessible.png;Stretch;0;";
        ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn", "Background", img_bg);
        ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn", "BackgroundHover", img_bg);
        ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn", "BackgroundPressed", img_bg);
    end;
    
    -- 对banner栏的error_promt进行截断处理
    cut_error_prompt_txt = function(err_prompt_txt)
        -- 不管中文英文，这里长度大于20，都做截断
        local is_need_cut_prompt = ui_utility.is_over_char_count(err_prompt_txt, 20);
        local out_str = err_prompt_txt;
        local b_is_cut = false;
        if true == is_need_cut_prompt then
            out_str = U8toCUIStrn(err_prompt_txt, 19, 1);
            b_is_cut = true;
        end;
        return out_str, b_is_cut;
    end;

     -- 显示插件的状态和文本
    show_plugin_status_text = function(state_value, fProcess)
        if ierd_tgp.game_library.KNEEDUPDATE == state_value then
            state_operation_panel.set_plugin_need_update_status();
            state_operation_panel.set_helper_area_enable_state(TRUE);
        elseif ierd_tgp.game_library.KNORMAL == state_value then
            state_operation_panel.set_helper_area_enable_state(TRUE);
        elseif ierd_tgp.game_library.KWAITTINGUPDATE == state_value then  -- 等待更新
            local background = "ONEIMAGE:bottom_bar\\wait_update.png;Stretch;0;";
            state_operation_panel.set_status_text_helper(state_value, background);
            state_operation_panel.set_helper_area_enable_state(FALSE);
        elseif ierd_tgp.game_library.KUPDATTING == state_value then  -- 正在更新
            local status_txt = state_operation_panel.get_plugin_updating_status_text(fProcess);
            state_operation_panel.set_plugin_updating_status(fProcess, status_txt);
            state_operation_panel.set_helper_area_enable_state(FALSE);
        elseif ierd_tgp.game_library.KUPDATEFAIL == state_value then  -- 更新失败，显示开始游戏按钮
            state_operation_panel.set_helper_area_enable_state(FALSE);
        end
    end;
    get_plugin_updating_status_text = function(fProcess)
        local status_txt = "";
        if fProcess == nil then
            status_txt = LoadStr(ID_BT_HELPER_UPDATING);
        else
            status_txt = string.format("%s %.2f%%", LoadStr(ID_BT_HELPER_UPDATING), fProcess);
        end
        return status_txt;
    end;

    set_plugin_updating_status = function(fProcess, status_txt)
        state_operation_panel.set_progress_info_helper(fProcess, status_txt);
        -- 设置右边按钮的状态
        local updating_downing_cnt_id = ui_utility.get_ctrl_id_by_path(frame_bottom_view.status_operation_id_, "UpdatingOrDowningCnt");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_left", "Visible", "false");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_right", "Visible", "false");
        ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_gift", "Visible", "false");
    end;

    set_plugin_need_update_status = function()
        state_operation_panel.set_start_update_status(LoadStr(ID_PL_UPDATEPL), 25);
    end;

    set_helper_area_enable_state = function(enable_state)
        local p_helper_ctrl = ui_utility.get_ctrl_ptr_by_id(frame_bottom_view.bottom_helper_area_id_);
        if p_helper_ctrl ~= nil then
            p_helper_ctrl:Enable(enable_state);
        end
    end;

    format_speed = function(download_speed)
        local speed_str = "";
        if (download_speed >= 1000 * 1024) then
            local speed = download_speed / (1024 * 1024);
            speed_str = string.format("%.2f MB/s", speed);
        else
            local speed = download_speed / 1024;
            speed_str = string.format("%d KB/s", speed);
        end
        return speed_str;
    end;

    format_remain_time = function(remain_time)
        local remain_str = "";
        if remain_time > 356400 then
            remain_str = "--:--:--";
        else
            remain_str = string.format("%.2d:%.2d:%.2d", math.floor(remain_time / (60 * 60)), 
                math.floor(remain_time /60 % 60), math.floor(remain_time % 60));
        end
        if remain_str == "00:00:00" then
            remain_str = ""
        end
        return remain_str;
    end;

    -- 事件处理
    -- 执行游戏的相关操作
    click_right_btn_game_action = function()
        -- 包含启动，更新，取消，重试，安装，下载
        if frame_bottom_view.game_and_plugin_state_tbl_.game == nil then return end

        local state_value = frame_bottom_view.game_and_plugin_state_tbl_.game.status;
        local sub_state_value = frame_bottom_view.game_and_plugin_state_tbl_.game.sub_status;
        local game_id = frame_bottom_view.game_and_plugin_state_tbl_.game.game_id;
        local report_op_type = "";

        -- 获取选择的区服：
        local server_id = 0;
        local game_servers = banner_model.get_game_servers(game_id);
        if game_servers ~= nil then
            server_id = game_servers.selleted;
        end

        if ierd_tgp.game_library.GAME_STATE_NORMAL == state_value  or 
            ierd_tgp.game_library.GAME_STATE_UNKNOWN == state_value then
            -- 点击启动游戏时 从下载管理器移除
            comm_center.call_service("Svr_RemoveTaskFromDownloadMgr", {game_id = game_id});
            -- 启动游戏
            if false == frame_bottom_model.is_all_protocol_agree(frame_bottom_view.current_select_module_id_) then
--                -- 不同意用户协议，不能启动游戏
--                local error_msg = "尊敬的用户，您需要阅读并同意用户协议才能登陆游戏";

--                local param = {
--                    position = "center",
--                    title = "用户协议提示",
--                    width = 480,
--                    height = 230,
--                    titleIcon = "",
--                    tipsIcon = poptips_icons.kWarning,
--                    descTitle = "",
--                    desc = error_msg,
--                    okBtn = {
--                        visible = "false",
--                        text = "确定",
--                        handle =  function()
--                        end,
--                    },
--                    cancelBtn = {
--                        visible = "true",
--                        text = "确定",
--                        handle = function()
--                        end,
--                    }
--                };
--                ui_utility.show_tips(param);
                frame_bottom_view.show_contract_no_check_tips(true);
                -- 启动一个超时定时器
                base_utility.add_interval(
                    "state_operation_panel.handle_show_contact_no_check_tips", 5 * 1000); 
                return;
            end
            if frame_bottom_model.is_all_protocol_agree(frame_bottom_view.current_select_module_id_) then
            frame_bottom_view.show_protocol_tips(false);
            end
            if state_operation_panel.is_allow_continue_operation_helper(game_id, true) then
                if frame_bottom_control.need_contact_netbar_manager(game_id) == false then
                    state_operation_panel.StartGame(game_id, server_id);
                    --frame_bottom_control.launch_game(game_id, server_id);
                    report_op_type = "start_game";
                end
            end
        elseif state_value == ierd_tgp.game_library.GAME_STATE_NEED_UPDATE then
            -- 更新操作，判断当前是暂停状态还是需要更新状态
            local pause_status = 0;
            if sub_state_value ~= ierd_tgp.game_library.GAME_UPDATE_DLC_NEED_UPDATE then
                pause_status = frame_bottom_model.get_game_update_pause_status(game_id);
            end
            if 0 ~= pause_status then
                frame_bottom_control.excute_game_act(GameActions.kCancelUpdate, game_id);
                report_op_type ="cancel_update_game";    
            else
                if state_operation_panel.is_allow_continue_operation_helper(game_id) then
                    frame_bottom_control.excute_game_act(GameActions.kUpdateGame, game_id, server_id);
                    report_op_type = "update_game";
                    wg_frame_bottom_control.on_update_game_execute(game_id);
                end
            end
        elseif state_value == ierd_tgp.game_library.GAME_STATE_UPDATING then
            if sub_state_value == ierd_tgp.game_library.GAME_UPDATE_DLC_UPDATING then
                if state_operation_panel.cur_updating_dlc_id_ ~= 0 then
                    local desc_text = LoadStr("CANCEL_UPDATE_GAME_DESC");
                    local desc_title_text = LoadStr("CANCEL_UPDATE_GAME_DESC_TITLE");
            
                    local param = {
                        position = 'center',--参数值: rbottom-右下角，center-居中
                        title = LoadStr("POP_TIPS_TIPS"),
                        width = 480,
                        height = 230,
                        titleIcon = "",
                        icon = "",
                        tipsIcon = "",
                        descTitle = desc_title_text,
                        desc = desc_text,
                        cancelBtn = {
                            visible = true,
                            text = LoadStr("CANCEL_UPDATE_CANCEL"),
                            handle = function()
                            end
                        },
                        okBtn = {
                            visible = true;
                            text = LoadStr("CANCEL_UPDATE_EXIT"),
                            handle = function()
                                comm_center.call_service("Svr_RailHost_OperateDlc", 
                                    {action = "CancelDownloadDlc", game_id = game_id, dlc_id = state_operation_panel.cur_updating_dlc_id_});
                                poptips_control.close_tips();
                            end
                        }
                    }
                    poptips_control.show_tips(param);
                end
                return;
            end
            -- 取消更新
            frame_bottom_control.excute_game_act(GameActions.kCancelUpdate, game_id);
            report_op_type = "cancel_update_game";
        elseif state_value == ierd_tgp.game_library.GAME_STATE_UPDATE_FAIL then
            -- 重试更新
            if state_operation_panel.is_allow_continue_operation_helper(game_id) then
                state_operation_panel.update_game_helper(game_id);
                report_op_type = "re_update_game";
            end
        elseif state_value == ierd_tgp.game_library.GAME_STATE_DOWNLOADED then
            -- 安装
            if state_operation_panel.is_allow_continue_operation_helper(game_id) then
                frame_bottom_control.excute_game_act(GameActions.kInstallGame, game_id);
                report_op_type = "install_game";
            end
        elseif state_value == ierd_tgp.game_library.GAME_STATE_DOWNLOAD_FAIL then
            -- 重试下载
            if state_operation_panel.is_allow_continue_operation_helper(game_id) then
                state_operation_panel.download_game_helper(game_id);
                report_op_type = "re_download_game";
            end
        elseif state_value == ierd_tgp.game_library.GAME_STATE_INSTALLING then
            -- 取消安装(暂时不支持)
        elseif state_value == ierd_tgp.game_library.GAME_STATE_BROKEN then
            -- 支持重新下载则下载，否则不处理
            if sub_state_value == 1 then
                -- 重新下载
                -- 先尝试卸载掉旧版本再重新下载
                if state_operation_panel.is_allow_continue_operation_helper(game_id) then
                    local result_info = comm_center.call_service("Svr_UninstallBrokenGame",
                                             {game_id = game_id});
                    if result_info == nil or result_info.can_uninstall == nil or 
                        result_info.can_uninstall ~= 1 then
                        state_operation_panel.download_game_helper(game_id);
                        report_op_type = "re_download_game";
                    else
                        base_utility.log("[state_operation_panel][click_right_btn_game_action] uninstall first");
                    end
                end
            else
                base_utility.log("[state_operation_panel][click_right_btn_game_action] game_state is brken, and not support redownload");
            end;
            
        elseif state_value == ierd_tgp.game_library.GAME_STATE_NOT_INSTALLED then
            -- 下载游戏
            if state_operation_panel.is_allow_continue_operation_helper(game_id) then
                frame_bottom_control.excute_game_act(GameActions.kDownloadGame, game_id);
                report_op_type = "download_game";
                wg_frame_bottom_control.on_download_game_execute(game_id);
            end
        elseif state_value == ierd_tgp.game_library.GAME_STATE_DOWNLOAD_PAUSED then
            frame_bottom_control.excute_game_act(GameActions.kCancelDownload, game_id); 
            report_op_type = "cancel_download_game"; 
        elseif state_value == ierd_tgp.game_library.GAME_STATE_DOWNLOADING then
            frame_bottom_control.excute_game_act(GameActions.kCancelDownload, game_id);
            report_op_type = "cancel_download_game";
        else
            base_utility.log(string.format("[frame_bottom] on_right_btn_click, ignore status:%d", state_value));
        end
        -- 数据上报
        if report_op_type ~= "" then
            state_operation_panel.report_game_operation(game_id, report_op_type);
        end
    end;

    -- 设置为64位启动
    Set64BitLaunch = function(game_id, is_64bit)
        local   zParam = {};

        zParam["game_id"]  = game_id;

        if is_64bit then
            zParam["is_64bit"] = 1;
        else
            zParam["is_64bit"] = 0;
        end;

        comm_center.call_service("Svr_Set64BitLaunch", zParam);

        TGPLog.LogI("WOW64", "Set 64 bit launch:" .. tostring(game_id) ..
                    ", is 64bit: " .. tostring(is_64bit));
    end;

    -- 启动游戏
    StartGame = function(game_id, service_id)
        -- 判断登录类型，能否启动对应的游戏
        if WGGameAction.IsFilterGameInAccLaunchCfg(game_id) then
                WGGameAction.PopTipsForSwitchQQLogin();
                return;
        end;
    
        if TLoginModule.GetLoginAccountType() == TLoginModule.LOGIN_ACCOUNT_TYPE.KWeChatLogin and 
            (game_id == GAME_ID.GAME_ID_LOL or game_id == GAME_ID.GAME_ID_LOL_TEST) then
             ierd_tgp.tpf_ui.Require("frame_bottom\\wechat_bind_view.lua");
             wechat_bind_view.InitView(game_id, service_id);
             if frame_bottom_model.is_lol_bind_switch_open() then
                 -- wechat_bind_view.ShowNoBindView();
                 frame_bottom_model.lol_game_id = game_id;
                 frame_bottom_model.lol_service_id = service_id;
                 frame_bottom_model.query_lol_is_wechat_bind();    
             else
                 if frame_bottom_model.need_show_wechat_bind_qq_wnd then
                     wechat_bind_view.ShowView(); 
                 end
             end
        else 
            state_operation_panel.StartGameHelper(game_id, service_id);
        end
    end;

    StartGameHelper = function(game_id, service_id)
        local   zParam = {};
        zParam["game_id"] = game_id;
        local   zTemp = comm_center.call_service("Svr_IsSupport64Bit", zParam);

        local   svr_is_in_game_streaming_param = {};
        svr_is_in_game_streaming_param["game_id"] = tostring(game_id);

        local   svr_is_in_game_streaming =
                  comm_center.call_service("Svr_IsGameInStreaming", svr_is_in_game_streaming_param);
        local   svr_is_cloud_game_running =
        comm_center.call_service("Svr_RailHost_IsCloudGameRunning", svr_is_in_game_streaming_param);
        
        -- 支持64位启动
        if (nil ~= zTemp) and (nil ~= zTemp["support"]) and (0 ~= tonumber(zTemp["support"])) then
            TGPLog.LogI("WOW64", "Game support 64 bit launch:" .. tostring(game_id));

            if nil ~= svr_is_cloud_game_running and nil ~= svr_is_cloud_game_running.is_running and
                0 ~= svr_is_cloud_game_running.is_running then
                local json_tbl = {};
                json_tbl.game_id = game_id;
                local json_str = base_utility.table_to_json(json_tbl);
                event_center.send_event(
                    popup_wnd_event.SHOW_CLOUD_GAME_ALREADY_RUNNING_TIPS, json_str);
                return;
            end;

            --  如果在串流中，则默认按操作系统区分
            if nil ~= svr_is_in_game_streaming and nil ~= svr_is_in_game_streaming["is_in_streaming"] and 0~=tonumber(svr_is_in_game_streaming["is_in_streaming"]) then
                if nil~= svr_is_in_game_streaming["is_64_bit"] and 0 ~= tonumber(svr_is_in_game_streaming["is_64_bit"]) then
                    state_operation_panel.Set64BitLaunch(game_id, true);
                    frame_bottom_control.launch_game(game_id, service_id);

                    TGPLog.LogI("WOW64", "Start streaming game(select 64Bit):" .. tostring(game_id) ..
                      " ServerID: " .. tostring(service_id) );
                    return;
                else
                    state_operation_panel.Set64BitLaunch(game_id, false);
                    frame_bottom_control.launch_game(game_id, service_id);

                    TGPLog.LogI("WOW64", "Start streaming game(select 32Bit):" .. tostring(game_id) ..
                            " ServerID: " .. tostring(service_id));
                    return;
                end;
            end


            local   sTipMsg = LoadStr("FRAME_BOTTOM_BIT_TIPS");
            local   bStarted = false;

            local param = 
            {
                position = "center",
                title = LoadStr("FRAME_BOTTOM_START_GAME"),
                width = 460,
                height = 230,
                titleIcon = "",
                tipsIcon = poptips_icons.kInfo,
                descTitle = "",
                desc = sTipMsg,
                okBtn = 
                {
                    visible = "true",
                    text = LoadStr("FRAME_BOTTOM_64_BIT"),
                    handle =  function()
                        if not bStarted then
                            bStarted = true;

                            state_operation_panel.Set64BitLaunch(game_id, true);
                            frame_bottom_control.launch_game(game_id, service_id);

                            TGPLog.LogI("WOW64", "Start game(select 64Bit):" .. tostring(game_id) ..
                                        " ServerID: " .. tostring(service_id));
                            poptips_control.close_tips();
                        end;
                    end,
                },
                cancelBtn = 
                {
                    visible = "true",
                    text = LoadStr("FRAME_BOTTOM_32_BIT"),
                    handle = function()
                        if not bStarted then
                            bStarted = true;
                            
                            state_operation_panel.Set64BitLaunch(game_id, false);
                            frame_bottom_control.launch_game(game_id, service_id);

                            TGPLog.LogI("WOW64", "Start game(select 32Bit):" .. tostring(game_id) ..
                                        " ServerID: " .. tostring(service_id));
                        end;
                    end,
                },
                close_means_cancel = false,
            };

            ui_utility.show_tips(param);
        else
            TGPLog.LogI("WOW64", "Game do NOT support 64 bit launch:" .. tostring(game_id));
            frame_bottom_control.launch_game(game_id, service_id);
        end;
    end;

    click_left_btn_game_action = function()
        -- 包含暂停, 继续操作
        if frame_bottom_view.game_and_plugin_state_tbl_.game == nil then return end
        local state_value = frame_bottom_view.game_and_plugin_state_tbl_.game.status;
        local sub_state_value = frame_bottom_view.game_and_plugin_state_tbl_.game.sub_status;
        local game_id = frame_bottom_view.game_and_plugin_state_tbl_.game.game_id;
        base_utility.log("[state_operation_panel]click_left_btn_game_action, ")
        if state_value == ierd_tgp.game_library.GAME_STATE_DOWNLOADING then
            -- 暂停下载操作
            frame_bottom_control.excute_game_act(GameActions.kPauseDownload, game_id);
            report_op_type = "pause_download_game";
        elseif state_value == ierd_tgp.game_library.GAME_STATE_DOWNLOAD_PAUSED then
            -- 继续下载操作
            if state_operation_panel.is_allow_continue_operation_helper(game_id) then
                frame_bottom_control.excute_game_act(GameActions.kContinueDownload, game_id);
                report_op_type = "continue_download_game";
            end
        elseif state_value == ierd_tgp.game_library.GAME_STATE_NEED_UPDATE then
            -- 继续更新操作
            local use_tinysetup = frame_bottom_model.get_game_update_mode(game_id);
            if use_tinysetup ~= 1 then
                frame_bottom_control.excute_game_act(GameActions.kUpdateGame, game_id);
            else
                --使用tinysetup的继续更新
                --frame_bottom_control.excute_game_act(GameActions.kContinueUpdate, game_id);
                local param = {};
                param["game_id"] = game_id;
                comm_center.call_service("i_service_continue_update_game", param);
            end
            report_op_type = "update_game";
        elseif state_value == ierd_tgp.game_library.GAME_STATE_UPDATING then
            if sub_state_value == ierd_tgp.game_library.GAME_UPDATE_DLC_UPDATING then
                if state_operation_panel.cur_updating_dlc_id_ ~= 0 then
                    if state_operation_panel.cur_dlc_state_ == dlcState.Updating or 
                            state_operation_panel.cur_dlc_state_ == dlcState.Downloading then
                        comm_center.call_service("Svr_RailHost_OperateDlc", 
                            {action = "PauseDownloadDlc", game_id = game_id, dlc_id = state_operation_panel.cur_updating_dlc_id_});
                    elseif state_operation_panel.cur_dlc_state_ == dlcState.DownloadingPause then
                        comm_center.call_service("Svr_RailHost_OperateDlc",
                            {action = "ResumeDownloadDlc", game_id = game_id, dlc_id = state_operation_panel.cur_updating_dlc_id_});
                    end
                end
                return;
            end
            -- 暂停更新
            frame_bottom_control.excute_game_act(GameActions.kPauseUpdate, game_id);
            report_op_type = "pause_update_game";
        end
        if report_op_type ~= "" then
            state_operation_panel.report_game_operation(game_id, report_op_type);
        end
    end;
    -- 执行助手的相关操作(助手更新只能取消，不能暂停和继续)
    click_left_btn_plugin_action = function()
        local game_id = frame_bottom_view.game_and_plugin_state_tbl_.plugin.game_id;
        local state_value = frame_bottom_view.game_and_plugin_state_tbl_.plugin.status;
        if ierd_tgp.game_library.KUPDATTING == state_value then
            -- 暂停更新
            frame_bottom_control.excute_game_act(GameActions.kPauseUpdatePlugin, game_id);
        end
     end;

     click_right_btn_plugin_action = function()
        local game_id = frame_bottom_view.game_and_plugin_state_tbl_.plugin.game_id;
        local state_value = frame_bottom_view.game_and_plugin_state_tbl_.plugin.status;
        local report_op_type = "";
        if ierd_tgp.game_library.KUPDATTING == state_value then
            -- 取消更新助手
            frame_bottom_control.excute_game_act(GameActions.kCancelUpdatePlugin, game_id);
            report_op_type = "cancel_update_plugin";
        elseif ierd_tgp.game_library.KUPDATEFAIL == state_value then
            -- 重新更新
            frame_bottom_control.excute_game_act(GameActions.kUpdatePlugin, game_id);
            report_op_type = "re_update_plugin";
        elseif ierd_tgp.game_library.KNEEDUPDATE == state_value then
            -- 更新助手
            frame_bottom_control.update_plugin(game_id);
            report_op_type = "update_plugin";
        end
        if report_op_type ~= "" then
            state_operation_panel.report_game_operation(game_id, report_op_type);
        end
     end;

     --显示礼包
     click_gift_btn_action = function ()
        local game_id = frame_bottom_view.game_and_plugin_state_tbl_.game.game_id;
        local gift_data = frame_bottom_model.get_download_gift_data(game_id);
        if gift_data == nil or gift_data.status == nil or gift_data.url == nil or gift_data.url == "" then
            base_utility.log("[frame_bottom][click_gift_btn_action]game_info does not exist. data = " .. tostring(gift_data));
            return;
        end

        if gift_data.status ~= 0 then
            -- 显示过则把标志位置为-1
            gift_data.status = -1;
            --local updating_downing_cnt_id = ui_utility.get_ctrl_id_by_path(frame_bottom_view.status_operation_id_, "UpdatingOrDowningCnt");
            --ui_utility.setproperty_by_path(updating_downing_cnt_id, "Cnt_Right\\btn_gift", "Visible", "false");

            -- 拉起礼包页面
            if gift_data.url ~= nil then
                comm_center.call_service("i_service_open_link_confirm_launch", gift_data.url);
                --数据上报
                state_operation_panel.report_gift_operation(game_id, "click", gift_data.url);
            end

        end; 
     end;

     set_helper_state = function(game_id)
        local base_info = banner_model.get_game_base_info(game_id);
        if base_info ~= nil then  
            local game_info_tbl = {
                game_id = game_id,
                game_type = base_info.type,
            };
            -- 设置助手区的状态
            frame_bottom_view.set_helper_area_visible_state(game_info_tbl);
        end; 
     end;

     notify_page_download_complete = function(game_id)
        if frame_bottom_view.is_open_gift_download_switch(game_id) then
             -- 判断是否是白名单用户
            if gift_white_list.get_gift_white_list_cfg(game_id) == 1 then
                local icon_offset = 0;
                local bottom_content_ptr = ui_utility.get_ctrl_ptr_by_path(frame_bottom_view.bottom_dlg_id_, "Bottom_Content_Pnl");
                if bottom_content_ptr ~= nil then
                    local content_rect = bottom_content_ptr:GetRectEx(FALSE,TRUE);
                    icon_offset = content_rect.right;
                end

                local callback_func = web_register_center.get_func_by_browser(
                    "hover_gift_icon_event", CID_MAINFRAME_QBWEB);
                if callback_func ~= nil and callback_func ~= "" then
                    local rsp_tbl = web_utility.notify_event_comm_data("hover_gift_icon_event");
                    rsp_tbl.data.cur_percent = 100;
                    rsp_tbl.data.percent = 100;
                    rsp_tbl.data.game_id = game_id;
                    rsp_tbl.data.position = icon_offset;
                    web_utility.lua_call_js_ex(callback_func, 
                            base_utility.table_to_json(rsp_tbl), CID_MAINFRAME_QBWEB);
                end     
            end
        end
     end;

     is_game_last_action_switch_branch = function(game_id)
        local is_switch_branch = 0;
        local z_param = {};
        z_param["game_id" ] = game_id;
        local data_out = comm_center.call_service("Svr_IsGameLastActionSwitchBranch", z_param);
        if data_out ~= nil and data_out.is_switch_branch == 1 then
            is_switch_branch = 1;
        else
            is_switch_branch = 0;
        end
        return is_switch_branch;
     end;

     update_game_helper = function(game_id)
        -- 因为多分支版本，先判断是否已经切换了分支
        if state_operation_panel.is_game_last_action_switch_branch(game_id) == 1 then
            local game_lib =
                base_utility.get_component_adapter("IGame_library",
                    "ierd_tgp.game_library.Get_game_library_adapter();");
            if game_lib ~= nil then
                game_lib:SwitchBranch(game_id, 0);
            end
        else
            frame_bottom_control.excute_game_act(GameActions.kUpdateGame, game_id);
        end 
     end;

     download_game_helper = function(game_id)
        if state_operation_panel.is_game_last_action_switch_branch(game_id) == 1 then
            local game_lib =
                base_utility.get_component_adapter("IGame_library",
                    "ierd_tgp.game_library.Get_game_library_adapter();");
            if game_lib ~= nil then
                game_lib:SwitchBranch(game_id, 0);
            end
        else
            frame_bottom_control.excute_game_act(GameActions.kDownloadGame, game_id);
        end 
     end;

    -- 用户操作上报
    report_game_operation = function(game_id, operation_type)
        local   qosData = ierd_tgp.tpf_ui.LuaQosDataEx:new();
        local   kvData = {};

        kvData["game_id"] = game_id;
        kvData["operation" ] = operation_type;
        kvData["user_id"] = state_operation_panel.get_self_uin();
        qosData.oc_type    = 1;
        qosData.qos_kind   = ierd_tgp.adapt_for_imports.qos.Qos_kind.kGameUpdateLackSpace;
        qosData.game_id = game_id;
        qosData.str_action = "main_window";
        qosData.str_type   = "bottom_bar";
        qosData.str_json   = base_utility.table_to_json(kvData);

        base_utility.lua_qos_ex(qosData);
        qosData:delete();
    end;

    -- 用户操作上报
    report_gift_operation = function(game_id, operation_type, url)
        local   qosData = ierd_tgp.tpf_ui.LuaQosDataEx:new();
        local   kvData = {};

        kvData["game_id"] = game_id;
        kvData["operation" ] = operation_type;
        kvData["user_id"] = state_operation_panel.get_self_uin();
        kvData["url"] = url;
        qosData.oc_type    = 1;
        qosData.qos_kind   = ierd_tgp.adapt_for_imports.qos.Qos_kind.kGameUpdateLackSpace;
        qosData.game_id = game_id;
        qosData.str_action = "main_window";
        qosData.str_type   = "bottom_gift";
        qosData.str_json   = base_utility.table_to_json(kvData);

        base_utility.lua_qos_ex(qosData);
        qosData:delete();
    end;

    -- 获取自己的UIN
    get_self_uin = function()
        if (nil == state_operation_panel.self_user_id_) or (0 == state_operation_panel.self_user_id_) then
            local   zTemp = comm_center.call_service("LoginSvr_GetSelfUin", {});

            if nil ~= zTemp["uin"] then
                state_operation_panel.self_user_id_ = zTemp["uin"];
            else
                TGPLog.LogE("frame_bottom", "Get self UIN fail.");
            end;
        end;
        return state_operation_panel.self_user_id_;
    end;

    is_external_update = function(game_id)
        base_utility.log(
            string.format("[state_operation_panel][is_external_update]game_id:%d", game_id));
        local param = {};
        param["game_id"] = game_id;
        local data_out = comm_center.call_service("i_service_using_external_update_game", param);
        local use_tinysetup = 0;
        if nil ~= data_out.is_external_update then
            use_tinysetup = data_out.is_external_update;
        end
        return use_tinysetup;
     end;

    is_other_wegame_oper_game = function(game_id, is_launch_oper)
        local param = {};
        param["game_id"] = game_id;
        if true == is_launch_oper then
            param["is_launch_oper"] = true;
        else
            param["is_launch_oper"] = false;
        end
        local data_out = comm_center.call_service("Svr_QueryMutexObjectExist", param);
        local is_operating = false;
        if data_out ~= nil and data_out.is_exist ~= nil then
            is_operating = data_out.is_exist;
        end
        return is_operating;
     end;

     is_other_wegame_preudate_game = function (game_id)
        local param = {};
        param["game_id"] = game_id;
        local data_out = comm_center.call_service("Svr_QueryPreUpdateMutexObjectExist", param);
        local is_operating = false;
        if data_out ~= nil and data_out.is_exist ~= nil then
            is_operating = data_out.is_exist;
        end
        return is_operating;
     end;

    set_operate_game_state_for_other_wegame = function(game_id, is_operate, is_launch_oper)
        local game_lib =
            base_utility.get_component_adapter("IGame_library",
                "ierd_tgp.game_library.Get_game_library_adapter();");
        if game_lib ~= nil then
            game_lib:SetGameOperStateMutex(game_id, is_operate, is_launch_oper);
        end
     end;

    show_other_wegame_operating_tip = function()
        local param = 
            {
                ignore_bp_ui = true,
                position = "center",
                title = LoadStr("POP_WND_COMMON_TITLE"),
                width = 460,
                height = 230,
                titleIcon = "",
                tipsIcon = poptips_icons.kInfo,
                descTitle = "",
                desc = LoadStr("FRAME_BOTTOM_OTHER_WEGAME_OPERATING_TIPS"),
                okBtn = 
                {
                    visible = "true",
                    text = LoadStr("POP_WND_COMMON_OK"),
                    handle =  function()
                        poptips_control.close_tips();
                    end,
                },
                cancelBtn = 
                {
                    visible = "false",
                    handle = function()
                    end,
                },
            };

            ui_utility.show_tips(param);
     end;

     is_allow_continue_operation_helper = function(game_id, is_launch_oper) 
        -- 先判断另一端是否已经启动
        local bAllowOperation = true;
        if state_operation_panel.is_other_wegame_oper_game(game_id, is_launch_oper) then
            bAllowOperation = false;
            state_operation_panel.show_other_wegame_operating_tip();
        else
            bAllowOperation = true; 
        end
        return bAllowOperation;
     end;

     is_allow_continue_preupdate = function (game_id)
        local bAllowOperation = true;
        if state_operation_panel.is_other_wegame_preudate_game(game_id) then
            bAllowOperation = false;
            state_operation_panel.show_other_wegame_operating_tip();
        else
            bAllowOperation = true; 
        end
        return bAllowOperation;
     end;

    set_operation_game_for_other_helper = function(game_id, game_state)
        if game_state == ierd_tgp.game_library.GAME_STATE_NEED_UPDATE then
            local pause_status = frame_bottom_model.get_game_update_pause_status(game_id);
            local is_switch_branch_game =
                state_operation_panel.is_game_last_action_switch_branch(game_id);
            if 0 ~= pause_status and 0 == is_switch_branch_game then
                state_operation_panel.set_operate_game_state_for_other_wegame(game_id, true);    
            else
                state_operation_panel.set_operate_game_state_for_other_wegame(game_id, false);
            end
        elseif game_state == ierd_tgp.game_library.GAME_STATE_UNKNOWN or
            game_state == ierd_tgp.game_library.GAME_STATE_NORMAL or
            game_state == ierd_tgp.game_library.GAME_STATE_BROKEN or
            game_state == ierd_tgp.game_library.GAME_STATE_UPDATE_FAIL or
            game_state == ierd_tgp.game_library.GAME_STATE_SERVER_UNAVAILABLE or
            game_state == ierd_tgp.game_library.GAME_STATE_DOWNLOADED or
            game_state == ierd_tgp.game_library.GAME_STATE_NOT_INSTALLED or
            game_state == ierd_tgp.game_library.GAME_STATE_DOWNLOAD_FAIL or
            game_state == ierd_tgp.game_library.GAME_STATE_UNVAILABLE then
            state_operation_panel.set_operate_game_state_for_other_wegame(game_id, false);
            state_operation_panel.set_operate_game_state_for_other_wegame(game_id, false, true);
        elseif  game_state == ierd_tgp.game_library.GAME_STATE_DOWNLOADING or
                game_state == ierd_tgp.game_library.GAME_STATE_INSTALLING or
                game_state == ierd_tgp.game_library.GAME_STATE_DOWNLOAD_PAUSED or
                game_state == ierd_tgp.game_library.GAME_STATE_UPDATING or
                game_state == ierd_tgp.game_library.GAME_STATE_UNINSTALLING then
            state_operation_panel.set_operate_game_state_for_other_wegame(game_id, true); 
        elseif game_state == ierd_tgp.game_library.GAME_STATE_LAUNCHING or 
            game_state == ierd_tgp.game_library.GAME_STATE_RUNNING then
            state_operation_panel.set_operate_game_state_for_other_wegame(game_id, true, true); 
        end
     end;

     handle_show_contact_no_check_tips = function ()
         base_utility.remove_interval("state_operation_panel.handle_show_contact_no_check_tips");
         frame_bottom_view.show_contract_no_check_tips(false);
     end;

     set_preupdate_mutex = function (game_id, is_oper)
        local data = {};
        data.game_id = game_id;
        data.is_set_oper = is_oper;
        comm_center.call_service("Svr_SetPreUpdateMutex", data);
     end;

     tick_progress_info_transition = function()
        state_operation_panel.progress_info_tick = state_operation_panel.progress_info_tick + 1;
        if state_operation_panel.progress_info_tick > 5 then
            state_operation_panel.progress_info_tick = 0;
            if state_operation_panel.progress_info_type == frame_bottom_progress_type.kProgressNormal then
                state_operation_panel.progress_info_type = frame_bottom_progress_type.kProgressFileSize;
            else
                state_operation_panel.progress_info_type = frame_bottom_progress_type.kProgressNormal;
            end
            return true;
        end
        return false;
     end;

     reset_progress_info_transition = function()
        state_operation_panel.progress_info_type = frame_bottom_progress_type.kProgressNormal;
        state_operation_panel.progress_info_tick = 0;
     end;

     get_progress_info_text = function(fProgress)
        local text = '';
        if state_operation_panel.progress_info_type == frame_bottom_progress_type.kProgressNormal then
            if nil ~= fProgress then
                text = string.format("%.2f%%", fProgress);
            end
        else
            local info = comm_center.call_service("i_service_gamedl_mgr_get_task_info",
                                    { game_id = frame_bottom_control.get_current_select_module() });
            if nil ~= info and nil ~= info.task_info then
                local tbl = base_utility.json_to_table(info.task_info) or {};
                if next(tbl) ~= nil then
                    text = string.format("%s / %s", base_utility.format_size(tbl.downloaded_size),
                    base_utility.format_size(tbl.total_size));
                end
            end
        end
        return text;
     end;

    
    refresh_normal_state_bg = function(game_state) 
        if ierd_tgp.game_library.GAME_STATE_NORMAL == game_state then 
            local state_op_ctn_id = ui_utility.get_ctrl_id_by_path(
                                     frame_bottom_view.status_operation_id_, "StateOperationCnt");
            if false == frame_bottom_model.is_all_protocol_agree(
                                                frame_bottom_view.current_select_module_id_) then
                local bk_img = "ONEIMAGE:bottom_bar\\play_gray.png?Stretch;0;";
                if state_operation_panel.is_cloud_game_ then
                    bk_img = "ONEIMAGE:bottom_bar\\with_menu\\play_gray.png?Stretch;0;";
                end;
                ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn", "Background", 
                                               bk_img);
                ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn", "BackgroundHover", 
                                               bk_img);
                ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn", "BackgroundPressed", 
                                               bk_img);
            else
                ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn", "Background", 
                     state_operation_panel.operation_btn_using_background_[game_state].background);
                ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn", "BackgroundHover", 
                     state_operation_panel.operation_btn_using_background_[game_state].background_hover);
                ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn", "BackgroundPressed", 
                     state_operation_panel.operation_btn_using_background_[game_state].background);
                if state_operation_panel.is_cloud_game_ then
                    ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn\\GameMenuBtn", "Visible", "true");
                    local state_btn_normal_img = state_operation_panel.state_btn_background_[game_state].background;
                    local state_btn_hover_img = state_operation_panel.state_btn_background_[game_state].background_hover;
                    local state_btn_press_img = state_operation_panel.state_btn_background_[game_state].background_pressed;
                    ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn\\GameMenuBtn", "Background", state_btn_normal_img);
                    ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn\\GameMenuBtn", "BackgroundHover", state_btn_normal_img);
                    ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn\\GameMenuBtn", "BackgroundPressed", state_btn_press_img);
                else
                    ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn\\GameMenuBtn", "Visible", "false");
               end
            end;
        end
    end;

    refresh_normal_state_menu_btn_bg = function()
         local state_op_ctn_id = ui_utility.get_ctrl_id_by_path(
                                     frame_bottom_view.status_operation_id_, "StateOperationCnt");
        if state_operation_panel.is_cloud_game_ == false then
            ui_utility.setproperty_by_path(state_op_ctn_id, "OperationBtn\\GameMenuBtn",
                "Visible", "false");
            return;
        end
        local game_state = ierd_tgp.game_library.GAME_STATE_NORMAL;
        ui_utility.setproperty_by_path(state_op_ctn_id, "StateBtn\\GameMenuBtn", "Visible", "true");
        local state_btn_normal_img = state_operation_panel.state_btn_background_[game_state].background;
        local state_btn_hover_img = state_operation_panel.state_btn_background_[game_state].background_hover;
        local state_btn_press_img = state_operation_panel.state_btn_background_[game_state].background_pressed;
        ui_utility.setproperty_by_path(state_op_ctn_id, "StateBtn\\GameMenuBtn",
            "Background", state_btn_normal_img);
        ui_utility.setproperty_by_path(state_op_ctn_id, "StateBtn\\GameMenuBtn",
            "BackgroundHover", state_btn_normal_img);
        ui_utility.setproperty_by_path(state_op_ctn_id, "StateBtn\\GameMenuBtn",
            "BackgroundPressed", state_btn_press_img);
    end
};

state_operation_panel.init();
